package com.gztms.usermgnt.pojo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.*;
import org.springframework.data.annotation.Transient;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Zoey
 * @date 2023/3/27 20:59
 * @Description 角色及对应的菜单权限
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
@TableName(value="sys_role")
public class SysRole {
    @TableId
    private Integer id;
    private String name;
    private String code;
    private Integer status;
    @TableLogic
    private Integer isDelete;
    private String remark;
    @JsonIgnore
    @TableField(exist = false)
    private SysRole parent;
    @JsonIgnore
    @TableField(exist = false)
    private List<SysRole> children = new ArrayList<>();

    //获取父节点id
    @Transient
    public Integer getParentId() {
        return parent == null ? null : parent.getId();
    }


}
